package com.zhentao.controller;

import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.common.manger.dto.AnnouncementsFindDto;
import com.zhentao.model.common.manger.pojo.Announcements;
import com.zhentao.service.MaAnnouncementsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ma/MaAnnouncements")
@Api(tags = "公告接口")
public class MaAnnouncementsController {

    @Autowired
    private MaAnnouncementsService maAnnouncementsService;

    /**
     * 后台管理：公告新增
     * @param announcements
     * @return
     */
    @PostMapping("/maAnnouncementsInsert")
    @ApiOperation("公告新增")
    public ResponseResult maAnnouncementsInsert(@RequestBody Announcements announcements){
        return maAnnouncementsService.maAnnouncementsInsert(announcements);
    }

    /**
     * 后台管理：公告删除
     * @param id
     * @return
     */
    @PostMapping("/maAnnouncementsDelete/{id}")
    @ApiOperation("公告删除")
    public ResponseResult maAnnouncementsDelete(@PathVariable("id")Integer id){
        return maAnnouncementsService.maAnnouncementsDelete(id);
    }

    /**
     * 后台管理：公告修改
     * @param announcements
     * @return
     */
    @PostMapping("/maAnnouncementsUpdate")
    @ApiOperation("公告修改")
    public ResponseResult maAnnouncementsUpdate(@RequestBody Announcements announcements){
        return maAnnouncementsService.maAnnouncementsUpdate(announcements);
    }


    /**
     * 后台管理：公告查询
     * @param dto
     * @return
     */
    @PostMapping("/maAnnouncementsFindAll")
    @ApiOperation("公告查询")
    public ResponseResult maAnnouncementsFindAll(@RequestBody AnnouncementsFindDto dto){
        return maAnnouncementsService.maAnnouncementsFindAll(dto);
    }
    @GetMapping("/upAndDown/{id}")
    @ApiOperation("公告上下架")
    public ResponseResult upAndDown(@PathVariable("id")Integer id){
        return maAnnouncementsService.upAndDown(id);
    }
}
